Skip to content

feat(config): propagator plugin loading via entry points for declarative config#5098

Open
MikeGoldsmith wants to merge 10 commits into
open-telemetry:mainfrom
MikeGoldsmith:mike/config-propagator-plugin-loading
Open

feat(config): propagator plugin loading via entry points for declarative config#5098
MikeGoldsmith wants to merge 10 commits into
open-telemetry:mainfrom
MikeGoldsmith:mike/config-propagator-plugin-loading

Conversation

@MikeGoldsmith
Copy link
Copy Markdown
Member

@MikeGoldsmith MikeGoldsmith commented Apr 14, 2026

Description

Extends propagator support in declarative file configuration to handle custom (plugin) propagators in the composite list, matching the spec's PluginComponentProvider mechanism.

Depends on #5131 (additional_properties support for generated models).

Solution

_propagators_from_textmap_config() uses typed TextMapPropagatorConfig fields and additional_properties:

  • Known registry names (tracecontext, baggage) are bootstrapped directly from the SDK via _PROPAGATOR_REGISTRY
  • Known schema fields not in the registry (b3, b3multi) are loaded via load_entry_point("opentelemetry_propagator", name)
  • Unknown plugin names from additional_properties are also loaded via entry points

Custom propagator example

propagator:
  composite:
    - tracecontext: {}
    - my_custom_propagator: {}
[project.entry-points."opentelemetry_propagator"]
my_custom_propagator = "my_package:MyPropagatorClass"

Closes #5070

Extracts a generic `load_entry_point(group, name)` helper into `_common`
so that resource detector, exporter, propagator, and sampler plugin loading
in declarative file config can all use the same entry point lookup pattern
rather than duplicating it.

Refactors `_propagator.py` to use the new util, removing its inline
entry point lookup.

Assisted-by: Claude Sonnet 4.6
TextMapPropagator is changed from @DataClass to TypeAlias = dict[str, Any]
in models.py, preserving unknown propagator names (plugin names) as dict
keys through the config pipeline — same approach as Sampler.

_propagators_from_textmap_config() now iterates the dict's key-value pairs
directly. Known names (tracecontext, baggage) are bootstrapped from
_PROPAGATOR_REGISTRY. All other names — including b3, b3multi, and custom
plugin propagators — fall back to load_entry_point("opentelemetry_propagator",
name), matching the spec's PluginComponentProvider mechanism.

Assisted-by: Claude Sonnet 4.6
Python dataclasses don't enforce types at runtime, so factory
functions can accept raw dicts directly. This removes the need to
change TextMapPropagator from a @DataClass to a TypeAlias.

Assisted-by: Claude Opus 4.6 (1M context)
@MikeGoldsmith MikeGoldsmith marked this pull request as draft April 20, 2026 13:52
Use typed TextMapPropagatorConfig with additional_properties from
the @_additional_properties decorator instead of raw dict iteration.
Known propagators (tracecontext, baggage) are checked via typed fields
and _PROPAGATOR_REGISTRY. Known schema fields not in the registry
(b3, b3multi) and unknown plugin names from additional_properties
are loaded via entry points.

Assisted-by: Claude Opus 4.6
@MikeGoldsmith MikeGoldsmith marked this pull request as ready for review April 29, 2026 14:00
Copy link
Copy Markdown
Contributor

@tammy-baylis-swi tammy-baylis-swi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm too, just needs a quick lint.

@github-project-automation github-project-automation Bot moved this from Ready for review to Approved PRs in Python PR digest May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Approved PRs

Development

Successfully merging this pull request may close these issues.

feat(config): generic plugin loading for propagators in declarative config

2 participants